<?php
/**
 * User: papa
 * Date: 18/5/17
 * Time: 14:31
 */

namespace app\admin\controller;


use app\admin\model\FacePay;

class FacepayController extends  BaseController
{

    //当面付订单列表
    public function index()
    {
        if (request()->isPost()) {
            $post = request()->post();
            $data['time'] = [
                'start_time' => $post['start_time'],
                'end_time' => $post['end_time'],
            ];
            $data['like'] = [
                'sn' => $post['sn'],
            ];
            $where = FacePay::getSearch($data);
        }
        if(empty($where)) $where = null;
        $result = FacePay::where($where)->order('create_time','Asc')->paginate(8, false, [
            'type' => 'page\Page',
        ]);
        $this->assign('lists',$result);
        return $this->fetch();
    }
    
    //删除订单
    public function del($id)
    {
        if(FacePay::destroy($id)){
            return 1;
        }else{
            return 0;
        }
    }

    //批量删除订单
    public function delall()
    {
        $id = input('post.id/a');
        if(FacePay::destroy($id))
        {
            return ajaxMsg(1,'删除成功');
        }else{
            return ajaxMsg(0,'删除失败');
        }
    }
}